package cn.hx.mallBlog.service.impl;

import cn.hx.mallBlog.dao.CmsTopicCommentDao;
import cn.hx.mallBlog.entity.CmsTopicComment;
import cn.hx.mallBlog.service.CmsTopicCommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 专题评论表(CmsTopicComment)表服务实现类
 *
 * @author makejava
 * @since 2022-12-01 10:16:10
 */
@Service("cmsTopicCommentService")
public class CmsTopicCommentServiceImpl implements CmsTopicCommentService {
    @Resource
    private CmsTopicCommentDao cmsTopicCommentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public CmsTopicComment queryById(Long id) {
        return this.cmsTopicCommentDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<CmsTopicComment> queryAllByLimit(int offset, int limit) {
        return this.cmsTopicCommentDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param cmsTopicComment 实例对象
     * @return 实例对象
     */
    @Override
    public CmsTopicComment insert(CmsTopicComment cmsTopicComment) {
        this.cmsTopicCommentDao.insert(cmsTopicComment);
        return cmsTopicComment;
    }

    /**
     * 修改数据
     *
     * @param cmsTopicComment 实例对象
     * @return 实例对象
     */
    @Override
    public CmsTopicComment update(CmsTopicComment cmsTopicComment) {
        this.cmsTopicCommentDao.update(cmsTopicComment);
        return this.queryById(cmsTopicComment.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.cmsTopicCommentDao.deleteById(id) > 0;
    }

    @Override
    public List<CmsTopicComment> queryAll(CmsTopicComment cmsTopicComment) {
        return  this.cmsTopicCommentDao.queryAll(cmsTopicComment);
    }
}